package android.team.app.utility;

import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

/**
 * 
 * @author Nam_BT
 * 
 *         Build dialogs method
 * 
 */

public class SmartDialogUtility extends Dialog {

	private TextView tvTitle, tvMessage;
	private ImageView imgIcon, imgPositiveBtn, imgNegativeBtn;

	private DialogInterface.OnDismissListener positiveDismissListener;
	private DialogInterface.OnDismissListener negativeDismissListener;

	private View.OnClickListener defaultDismiss = new View.OnClickListener() {

		@Override
		public void onClick(View v) {
			dismiss();
		}
	};

	private View.OnClickListener positiveButtonClick = new View.OnClickListener() {

		@Override
		public void onClick(View v) {
			setOnDismissListener(positiveDismissListener);
			dismiss();
		}
	};
	
	private View.OnClickListener negativeButtonClick = new View.OnClickListener() {

		@Override
		public void onClick(View v) {
			setOnDismissListener(negativeDismissListener);
			dismiss();
		}
	};

	public SmartDialogUtility(Context context) {
		super(context);

	}

	// ================Standard dialog================//
	public static void dialogStandard(Context context, String title, int icon,
			String message, String bt1Name, OnClickListener onClickBt1,
			String bt2Name, OnClickListener onClickBt2, String bt3Name,
			OnClickListener onClickBt3) {

		// step 1: define dialog
		AlertDialog.Builder dialog = new AlertDialog.Builder(context);

		// step 2: add attribute for header dialog
		dialog.setIcon(icon);
		dialog.setTitle(title);

		// step 3 : add attribute for body dialog
		dialog.setMessage(message);

		if (bt1Name != null) {
			dialog.setPositiveButton(bt1Name, onClickBt1);
		}

		if (bt2Name != null) {
			dialog.setNegativeButton(bt2Name, onClickBt2);
		}

		if (bt3Name != null) {
			dialog.setNegativeButton(bt3Name, onClickBt3);
		}

		// step 4: show dialog
		dialog.show();

	}

	// ================Custom dialog================//

}
